home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / as / dist / output-file.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-01  |  1.9 KB  |  80 lines

  1. /* output-file.c -  Deal with the output file
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GAS, the GNU Assembler.
  5.  
  6. GAS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GAS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GAS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /*
  21.  * Confines all details of emitting object bytes to this module.
  22.  * All O/S specific crocks should live here.
  23.  * What we lose in "efficiency" we gain in modularity.
  24.  * Note we don't need to #include the "as.h" file. No common coupling!
  25.  */
  26.  
  27. /* #include "style.h" */
  28. #include <stdio.h>
  29.  
  30. void    as_perror();
  31.  
  32. static FILE *
  33. stdoutput;
  34.  
  35. void
  36. output_file_create (name)
  37.      char *        name;
  38. {
  39.   if ( ! (stdoutput = fopen( name, "w" )) )
  40.     {
  41.       as_perror ("Can't create object file", name);
  42.       as_fatal("Can't continue");
  43.     }
  44. }
  45.  
  46.  
  47.  
  48. void
  49. output_file_close (filename)
  50.      char *    filename;
  51. {
  52.   if ( EOF == fclose( stdoutput ) )
  53.     {
  54.       as_perror ("Can't close object file", filename);
  55.       as_fatal("Can't continue");
  56.     }
  57.   stdoutput = NULL;        /* Trust nobody! */
  58. }
  59.  
  60. void
  61. output_file_append (where, length, filename)
  62.      char *        where;
  63.      long int        length;
  64.      char *        filename;
  65. {
  66.  
  67.   for (; length; length--,where++)
  68.     {
  69.         (void)putc(*where,stdoutput);
  70.     if(ferror(stdoutput))
  71.       /* if ( EOF == (putc( *where, stdoutput )) ) */
  72.     {
  73.       as_perror("Failed to emit an object byte", filename);
  74.       as_fatal("Can't continue");
  75.     }
  76.     }
  77. }
  78.  
  79. /* end: output-file.c */
  80.